<?php

namespace App\Modules\Admin\Http\Controllers\Water\Member;

use App\Exceptions\Exception;
use App\Http\Controllers\Controller;
use App\Modules\Admin\Http\Controllers\BaseController;
use App\Modules\Admin\Services\Water\Member\UsersService;
use App\Modules\Admin\Services\Water\Vip\VipService;

class VipController extends BaseController
{
    public function __construct(VipService $service)
    {
        $this->service = $service;
    }

    /**
     * @param VipService $vipService
     * @return mixed
     */
    public function list(VipService $vipService)
    {
        $page = (int)request('page', 1);
        $pageSize = (int)request('pageSize', 20);
        $type = (int)request('type', 0);
        $data = $vipService->list($type,$page, $pageSize);
        return success($data);
    }

    /**
     * @param VipService $vipService
     * @return mixed
     * @throws Exception
     */
    public function create(VipService $vipService)
    {
        $type = (int)request('type', 0);
        $count = (int)request('count', 0);
        $vipService->create($type,$count);
        return success();
    }

    /**
     * @param VipService $vipService
     * @return mixed
     * @throws Exception
     */
    public function send(VipService $vipService)
    {
        $userId = (int)request('user_id', 0);
        $type = (int)request('type', 0);
        $vipService->send($userId,$type);
        return success();
    }
}
